

#include "cv.h"
#include "highgui.h"
#include <vector>

#include "Time.h"
#include "Histogram.h"
#include "Frame.h"

#include "Video.h"
#include "Transition.h"
#include "VisualRhythm.h"
#include "DetectTransitions.h"

#include "Test.h"

#include "Log.h"

#include <iostream>
using namespace std;

/**
* Calculate the different between two frame
**/
int Test::diff(Frame *a, Frame *b)
{
    int s = 0;
    if(a->getWidth() == b->getWidth() &&
        a->getHeight() == b->getHeight() )
    {
        for(int i=0; i<a->getWidth(); i++)
        {
            for(int j=0; j<a->getHeight(); j++)
            {
                s = s + abs(b->getPixel(i, j) - a->getPixel(i, j));
            }
        }
    }
    return s;
}

/**
* Test detect transition
**/
void Test::detectTransitions(Video* vdo, std::vector<Transition>* transitionList)
{
    vdo->seekFrame(0);
    Frame * f = vdo->getCurrentFrame();
    Frame * s = vdo->getNextFrame();
    while(s != NULL)
    {
        int sum = diff(f, s);
        cout << vdo->getCurrentPosition() << ":\t" << sum << endl;
        f = s;
        s = vdo->getNextFrame();
    }
}
